<template>
  <div id="lineEcharts" style="height:200px;width:84%;"></div>
</template>

<script>
import echarts from "echarts";
export default {
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.drawLineEcharts();
  },
  methods: {
    drawLineEcharts() {
      let myChart = echarts.init(document.getElementById("lineEcharts"));
      let option = {
        // backgroundColor: "#fff",
        tooltip: {
          trigger: "axis",
          backgroundColor: "rgba(72,179,255,0.6)",

          // formatter: function (params) {
          //     params = params[0];
          //     // var date = new Date(params.name);
          //     return '审核数: ' + data;
          // },
          axisPointer: {
            animation: false,
            lineStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "#48b3ff"
                  },
                  {
                    offset: 0.5,
                    color: "#48b3ff"
                  },
                  {
                    offset: 1,
                    color: "#48b3ff"
                  }
                ],
                global: false
              }
            }
          }
        },
        grid: {
          top: "6%",
          left: "5%",
          right: "5%",
          bottom: "20%"
        },
        xAxis: {
          show: true, //不显示X轴坐标
          type: "category",
          boundaryGap: false,
          axisLine: {
            //坐标轴轴线相关设置。数学上的x轴
            show: true
          },
          data: [
            "1月份",
            "2月份",
            "3月份",
            "4月份",
            "5月份",
            "6月份",
            "7月份",
            "8月份",
            "9月份",
            "10月份",
            "11月份",
            "12月份"
          ]
        },
        yAxis: {
          type: "value",
          name: "单位（件）",
          show: true, //不显示Y轴坐标
          axisTick: {
            show: false
          },
          axisLine: {
            lineStyle: {
              color: "red",
            }
          },

          splitLine: {
            lineStyle: {
              color: "rgba(131,101,101,0.2)",
              type: "dashed"
            }
          }
        },
        series: [
          {
            name: "产出数量(件)",
            type: "line",
            showSymbol: true,
            symbol: "circle",
            symbolSize: 12,
            smooth: 0.3,
            hoverAnimation: false,
            tooltip: {
              show: true
            },
            data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122],
            lineStyle: {
              normal: {
                color: "#48b3ff" // 线条颜色
              }
            },
            itemStyle: {
              normal: {
                color: "#fff",
                borderColor: "#48b3ff",
                borderWidth: 2
              }
            },
            areaStyle: {
              //区域填充样式
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(65, 165, 245,1)"
                    },
                    {
                      offset: 1,
                      color: "rgba(228, 244, 255,0)"
                    }
                  ],
                  false
                ),
                shadowBlur: 0
              }
            }
          }
        ]
      };

      if (option && typeof option === "object") {
        myChart.setOption(option, true);
      }
    }
  }
};
</script>

<style scoped lang="scss">
</style>
